#include <QApplication>
#include <QDebug>
#include <QTimer>

#include "InputServiceEngineDBusService.h"
#include "InputServiceEngineHandler.h"



int main(int argc, char** argv) {

    QApplication app(argc, argv);

    //qRegisterMetaType<QStringMap>(); //only for qt property system
    qDBusRegisterMetaType<QStringMap>();
    qDBusRegisterMetaType<QIntList>();
    qDBusRegisterMetaType<Int2>();
    qDBusRegisterMetaType<QInt2List>();
    
    InputServiceEngineHandler iseh;
    InputServiceEngineDBusService iseds(&iseh);


    bool result;
    QDBusConnection session = QDBusConnection::sessionBus();

    result = session.registerService(COM_CPIS_ENGINE_NAME);
    if (!result) {
        qWarning() << "register service failed";
        return -1;
    }

    result = session.registerObject(COM_CPIS_ENGINE_OBJECT_PATH, &iseh);
    if (!result) {
        qWarning() << "register object failed";
        return -1;
    }

    QTimer eventTimer;
    QObject::connect(&eventTimer, &QTimer::timeout, 
                     [&iseh]() {
        iseh.Event("lee", 1, "test", 5);
    });
    eventTimer.start(1000);

    return app.exec();

}
